package org.ilovecode.display 
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	
	/**
	 * ...
	 * @author Vjekoslav Ratkajec
	 */
	public class ApartmentLayoutInfoWindow extends MovieClip 
	{
		
		//{ region Stage elements
		
		public var titleTextField:TextField;
		
		//} endregion
		
		private var apartment:Apartment = null;
		
		public function ApartmentLayoutInfoWindow() 
		{
			
		}
		
		public function init(apartment:Apartment):void {
			this.apartment = apartment;
			configDisplay();
		}

		private function configDisplay():void {
			titleTextField.text = apartment.code + " - " + apartment.floor + " - DILATACIJA " + apartment.building;
			
			//Setup list of items
			var isGreyItem:Boolean = true;
			var count:uint = 1;
			for each (var room:Object in apartment.roomList) {
				var infoItem:ApartmentInfoItem = new ApartmentInfoItem();
				var color:uint = 0xFFFFFF;
				if (isGreyItem) {
					color = 0xB7B5B5;
					isGreyItem = false;
				} else {
					isGreyItem = true;
				}
				infoItem.init(String(count) + ". " + room.name, room.area, color);
				infoItem.x = 0;
				infoItem.y = this.height;
				this.addChild(infoItem);
				count++;
			}
			
			//Setup item total
			var totalItem:ApartmentInfoItem = new ApartmentInfoItem();
			totalItem.init("UKUPNA POVRŠINA", apartment.area, 0x47B93A);
			totalItem.x = 0;
			totalItem.y = this.height;
			this.addChild(totalItem);
			
		}
	}

}